<template>
  <FormCard>
    <render/>
  </FormCard>
</template>
<script setup>
import {createProps} from '@/utils';
import {h} from 'vue';
import FormComponentDelegate from '@comp/FormEngine/FormComponentDelegate.vue';
import FormCard from '@comp/FormEngine/field/Card/FormCard.vue';

defineOptions({name: 'Card'});
const props = defineProps({
  config: createProps(Object, () => undefined),
  context: createProps(Object, () => undefined),
});

function render() {
  let content = props?.config?.content || [];
  return content.map(item => renderItem(item)).filter(item => !!item);
}

function renderItem(item) {
  return h(FormComponentDelegate, {
    config: item,
    context: props.context,
  });
}
</script>